﻿using System.Linq;
using System.Xml.Serialization;
using ElectronicCommerce.Framework.Configuration.Attributes;

namespace ElectronicCommerce.Framework.Web.Configuration.Resource
{
    [ConfigFile("Pages.config")]
    [XmlRoot("pages", Namespace = "http://www.ElectronicCommerce.com/configuration")]
    public class PageConfiguration
    {
        [XmlElement("page")]
        public PageCollection Pages { get; set; }

        public PageInfo GetPageInfo(string name)
        {
            return Pages.Where(p => p.Name.ToLower() == name.ToLower()).SingleOrDefault();
        }
    }

    [ConfigFile("FrontPages.config")]
    [XmlRoot("pages", Namespace = "http://www.ElectronicCommerce.com/configuration")]
    public class FrontPageConfiguration
    {
        [XmlElement("page")]
        public PageCollection Pages { get; set; }

        public PageInfo GetPageInfo(string name)
        {
            return Pages.Where(p => p.Name.ToLower() == name.ToLower()).SingleOrDefault();
        }
    }
}
